﻿//
//	License: The MIT License (MIT)
//  Copyright (c) 2010 Kai Bidstrup 
//
//	http://ua6281.codeplex.com/
//
#define MANUAL

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using A6281;

namespace NetduinoBrilldea {
	public class Program {

		private const int PolkaDOTCount = 15;

		public static void Main() {
			
			Multiple multipleModules = new Multiple( PolkaDOTCount // number of daisy changed LED modules
				, Pins.GPIO_NONE // chip select pin
				, Pins.GPIO_PIN_D2 // data latch pin
				, Pins.GPIO_PIN_D0 // output enable pin
				, SPI.SPI_module.SPI1  // SPI module
				, ColorOrder.GRB_PolkaDOT ); // color to register mapping

			multipleModules.On = true;
#if CYLON
			DelaySet cylonDelaySet = new DelaySet( 50 );
			ChipColorSequence cylonSequence = ChipColorSequence.CreateCylon( PolkaDOTCount, ChipColor.PureRed, ChipColor.PureBlack );
			multipleModules.RunChipColorSequence( cylonSequence, cylonDelaySet );
#endif
#if XMAS
			DelaySet xmasDelaySet = new DelaySet( 200 );
			ChipColorSequence xmasSequence = ChipColorSequence.CreateXmas();
			multipleModules.RunChipColorSequence( xmasSequence, xmasDelaySet );
#endif
#if RAINBOW
			ChipColorSequence sequence = ChipColorSequence.CreateRainbow();
			DelaySet delay = new DelaySet( new Delay( 500 ) );
			multipleModules.RunChipColorSequence( sequence, delay );
#endif
#if MANUAL
			while ( true ) {
			    multipleModules.SetColorImmediate( ChipColor.PureRed );
				Thread.Sleep(1000);
				multipleModules.SetColorImmediate( ChipColor.PureBlack );
				Thread.Sleep( 1000 );
				multipleModules.SetColorImmediate( ChipColor.PureGreen );
				Thread.Sleep( 1000 );
				multipleModules.SetColorImmediate( ChipColor.PureBlack );
				Thread.Sleep( 1000 );
				multipleModules.SetColorImmediate( ChipColor.PureBlue );
				Thread.Sleep( 1000 );
				multipleModules.SetColorImmediate( ChipColor.PureBlack );
				Thread.Sleep( 2000 );
			}	
#endif
		}
	}
}
